package day8;
/*
* 构造方法互相调用时调用父类的构造方法
* */
public class Demo4 {
    public static void main(String[] args) {
        Son son = new Son("往事随风","王建国",52);

        System.out.println(son.nickName);
    }
}

class Father{
    String nickName;

    public Father(String nickName){
        this.nickName = nickName;
        System.out.println("父类的无参构造");
    }
}
class Son extends Father{
    String name;

    int age;

    //两参构造
    public Son(String name,String nickName){
        super(nickName);
        this.name = name;
        System.out.println("子类两参构造");
    }

    //可以使用子类构造方法对父类属性进行初始化
    public Son(String nickName,String name,int age){
        this(name,nickName);
        this.age = age;
        System.out.println("子类的三参构造");
    }

}
